//获取所在行业的值
$(".joystry").click(function() {
    var joyname = $(this).text();
    $(".joy-input").html(joyname + '<span class="caret-success com-ul1-right"></span>');
});

//2016/12/20选择技能类别
$(".sellect-skillness").click(function() {
    $(".sellect-skillness").removeClass("active");
    $(this).addClass("active")
});

// 获取城市
$(".city").click(function() {
    var cityname = $(this).text();
    $(".city-input").html(cityname + '<span class="caret-success com-ul1-right"></span>');
    var cityvar = $(this).val();
    getCity(cityvar);
});

$(document).on("click", ".citya", function() {
    var citynamea = $(this).text();
    $(".city-inputa").html(citynamea + '<span class="caret-success com-ul1-right"></span>');
});

// $('#myTab a').click(function(e) {
//     e.preventDefault()
//     $(this).tab('show')
// });

// 判断有没有选择技能标签
$(function() {
    skillon();
    isBrowser();

    function skillon() {
        if ($('#select-skill>span').length == 0) {
            $('.select-skill').css("display", "none");
            $(".register-skill").css("margin-top", "15px");
            $("#skill-h220").css("height", "220px");
            $(".more").css("margin-top", "35px");
        } else {
            $(".more").css("margin-top", "0");
            $('.select-skill').css("display", "block");
        }
    }

    function isBrowser() {
        var Sys = {};
        var ua = navigator.userAgent.toLowerCase();
        var s;
        (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1]:
            (s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
            (s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
            (s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
            (s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
        if (Sys.ie) { //Js判断为IE浏览器
            if (Sys.ie == '9.0') {
                //Js判断为IE 9
            } else if (Sys.ie == '8.0') {
                //Js判断为IE 8
                alert("aaa");
                $(".redxing").css("margin-left", "40px");
            } else {}
        }
        if (Sys.firefox) {
            //Js判断为火狐(firefox)浏览器
            $(".form-group.m-b20").css("width", "100%");
        }
        if (Sys.chrome) { //Js判断为谷歌chrome浏览器
        }
        if (Sys.opera) { //Js判断为opera浏览器
        }
        if (Sys.safari) { //Js判断为苹果safari浏览器
        }
    }

    // $(document).on("click", ".skill-ac", function() {
    //     $(this).remove();
    //     skillon();
    // });

    var skiid = 5;
    $(document).on("click", ".design", function() {
        if ($(this).hasClass("spanacitve")) {
            $(this).removeClass("spanacitve");
            var str = $(this).attr("id");
            if (str.length == 6) {
                str = str.substring(0, 4);
            } else if (str.length == 7) {
                str = str.substring(0, 5);
            } else {
                str = str.substring(0, 6);
            }
            $(this).removeClass("spanacitve");
            $("#" + str).remove();
            return;
        } else {
            if ($('#select-skill>span').length < 10) {
                var val = $(this).attr("value");
                $("#select-skill").append('<span value="'+val+'" id="' + "ski" + skiid + '" class="skill-ac skill-remove cp">' + $(this).html() + '</span>');
                $(this).attr('id', '' + "ski" + skiid + "id" + '');
                skillon();
                $("#skill-h220").css("height", "auto");
                $(this).addClass("spanacitve");
            } else {
                updateAlert("最多选择10个技能标签", 'alert-error');
            }
        }
        skiid++;
    });

    $(document).on("click", ".operate", function() {
        if ($(this).hasClass("spanacitve")) {
            $(this).removeClass("spanacitve");
            var str = $(this).attr("id");
            if (str.length == 6) {
                str = str.substring(0, 4);
            } else if (str.length == 7) {
                str = str.substring(0, 5);
            } else {
                str = str.substring(0, 6);
            }
            $(this).removeClass("spanacitve");
            $("#" + str).remove();
            return;
        } else {
            if ($('#select-skill>span').length < 10) {
                var val = $(this).attr("value");
                $("#select-skill").append('<span value="'+val+'" id="' + "ski" + skiid + '" class="skill-ac skill-remove cp">' + $(this).html() + '</span>');
                $(this).attr('id', '' + "ski" + skiid + "id" + '');
                skillon();
                $("#skill-h220").css("height", "auto");
                $(this).addClass("spanacitve");
            } else {
                updateAlert("最多选择10个技能标签", 'alert-error');
            }
        }
        skiid++;
    });

    $(document).on("click", ".technology", function() {
        if ($(this).hasClass("spanacitve")) {
            $(this).removeClass("spanacitve");
            var str = $(this).attr("id");
            if (str.length == 6) {
                str = str.substring(0, 4);
            } else if (str.length == 7) {
                str = str.substring(0, 5);
            } else {
                str = str.substring(0, 6);
            }
            $(this).removeClass("spanacitve");
            $("#" + str).remove();
            return;
        } else {
            if ($('#select-skill>span').length < 10) {
                var val = $(this).attr("value");
                $("#select-skill").append('<span value="'+val+'" id="' + "ski" + skiid + '" class="skill-ac skill-remove cp">' + $(this).html() + '</span>');
                $(this).attr('id', '' + "ski" + skiid + "id" + '');
                skillon();
                $("#skill-h220").css("height", "auto");
                $(this).addClass("spanacitve");
            } else {
                updateAlert("最多选择10个技能标签", 'alert-error');
            }
        }
        skiid++;
    });

    $(document).on("click", ".market", function() {
        if ($(this).hasClass("spanacitve")) {
            $(this).removeClass("spanacitve");
            var str = $(this).attr("id");
            if (str.length == 6) {
                str = str.substring(0, 4);
            } else if (str.length == 7) {
                str = str.substring(0, 5);
            } else {
                str = str.substring(0, 6);
            }
            $(this).removeClass("spanacitve");
            $("#" + str).remove();
            return;
        } else {
            if ($('#select-skill>span').length < 10) {
                var val = $(this).attr("value");
                $("#select-skill").append('<span value="'+val+'" id="' + "ski" + skiid + '" class="skill-ac skill-remove cp">' + $(this).html() + '</span>');
                $(this).attr('id', '' + "ski" + skiid + "id" + '');
                skillon();
                $("#skill-h220").css("height", "auto");
                $(this).addClass("spanacitve");
            } else {
                updateAlert("最多选择10个技能标签", 'alert-error');
            }
        }
        skiid++;
    });

    $(document).on("click", ".zineng", function() {
        if ($(this).hasClass("spanacitve")) {
            $(this).removeClass("spanacitve");
            var str = $(this).attr("id");
            if (str.length == 6) {
                str = str.substring(0, 4);
            } else if (str.length == 7) {
                str = str.substring(0, 5);
            } else {
                str = str.substring(0, 6);
            }
            $(this).removeClass("spanacitve");
            $("#" + str).remove();
            return;
        } else {
            if ($('#select-skill>span').length < 10) {
                var val = $(this).attr("value");
                $("#select-skill").append('<span value="'+val+'" id="' + "ski" + skiid + '" class="skill-ac skill-remove cp">' + $(this).html() + '</span>');
                $(this).attr('id', '' + "ski" + skiid + "id" + '');
                skillon();
                $("#skill-h220").css("height", "auto");
                $(this).addClass("spanacitve");
            } else {
                updateAlert("最多选择10个技能标签", 'alert-error');
            }
        }
        skiid++;
    });

    $(document).on("click", ".product", function() {
        if ($(this).hasClass("spanacitve")) {
            $(this).removeClass("spanacitve");
            var str = $(this).attr("id");
            if (str.length == 6) {
                str = str.substring(0, 4);
            } else if (str.length == 7) {
                str = str.substring(0, 5);
            } else {
                str = str.substring(0, 6);
            }
            $(this).removeClass("spanacitve");
            $("#" + str).remove();
            return;
        } else {
            if ($('#select-skill>span').length < 10) {
                var val = $(this).attr("value");
                $("#select-skill").append('<span value="'+val+'" id="' + "ski" + skiid + '" class="skill-ac skill-remove cp">' + $(this).html() + '</span>');
                $(this).attr('id', '' + "ski" + skiid + "id" + '');
                skillon();
                $("#skill-h220").css("height", "auto");
                $(this).addClass("spanacitve");
            } else {
                updateAlert("最多选择10个技能标签", 'alert-error');
            }
        }
        skiid++;
    });

    $(document).on("click", ".finance", function() {
        if ($(this).hasClass("spanacitve")) {
            $(this).removeClass("spanacitve");
            var str = $(this).attr("id");
            if (str.length == 6) {
                str = str.substring(0, 4);
            } else if (str.length == 7) {
                str = str.substring(0, 5);
            } else {
                str = str.substring(0, 6);
            }
            $(this).removeClass("spanacitve");
            $("#" + str).remove();
            return;
        } else {
            if ($('#select-skill>span').length < 10) {
                var val = $(this).attr("value");
                $("#select-skill").append('<span value="'+val+'" id="' + "ski" + skiid + '" class="skill-ac skill-remove cp">' + $(this).html() + '</span>');
                $(this).attr('id', '' + "ski" + skiid + "id" + '');
                skillon();
                $("#skill-h220").css("height", "auto");
                $(this).addClass("spanacitve");
            } else {
                updateAlert("最多选择10个技能标签", 'alert-error');
            }
        }
        skiid++;
    });

    $(document).on("click", ".other", function() {
        if ($(this).hasClass("spanacitve")) {
            $(this).removeClass("spanacitve");
            var str = $(this).attr("id");
            if (str.length == 6) {
                str = str.substring(0, 4);
            } else if (str.length == 7) {
                str = str.substring(0, 5);
            } else {
                str = str.substring(0, 6);
            }
            $(this).removeClass("spanacitve");
            $("#" + str).remove();
            return;
        } else {
            if ($('#select-skill>span').length < 10) {
                var val = $(this).attr("value");
                $("#select-skill").append('<span value="'+val+'" id="' + "ski" + skiid + '" class="skill-ac skill-remove cp">' + $(this).html() + '</span>');
                $(this).attr('id', '' + "ski" + skiid + "id" + '');
                skillon();
                $("#skill-h220").css("height", "auto");
                $(this).addClass("spanacitve");
            } else {
                updateAlert("最多选择10个技能标签", 'alert-error');
            }
        }
        skiid++;
    });

    $(document).on("click", ".skill-remove", function() {
        $(this).remove();
        var idski = $(this).attr("id");
        $("#" + idski + "id").removeClass("spanacitve");
    })

    $(document).on("click", ".bs-example>ul>li", function() {
        var skillselected = $(".bs-example>ul>li.active").text();
        var skillnotselect = $(this).text();
        var skillthis = $(this);
        if (skillselected != skillnotselect) {
            //if ($("#select-skill>span").length > 0) {
            //    $.confirm("提示", "只能选择一个领域，确认切换领域，已选标签将清空", function() {
            //        skiid = 0;
            //        $(".skill-ac").remove();
            //        $(".tab-pane>span").removeClass("spanacitve");
            //        $(".bs-example>ul>li").removeClass("active");
            //        skillthis.addClass("active");
            //        var skillid = skillthis.index();
            //        $(".tab-pane.fade").css("display", "none");
            //        $("#skill-" + skillid).css("display", "block");
            //    }, function() {
            //        return false;
            //    });
            //    $('body').css('padding-right', '0');
            //} else {
                $(".bs-example>ul>li").removeClass("active");
                skillthis.addClass("active");
                var skillid = skillthis.index();
                $(".tab-pane.fade").css("display", "none");
                $("#skill-" + skillid).css("display", "block");
            //}
        }
    });

    $(function() {
        function zoomImg(o) {
            var zoom = parseInt(o.style.zoom, 10) || 100;
            zoom += event.wheelDelta / 2; //可适合修改
            if (zoom > 0)
                o.style.zoom = zoom + '%';
        }
        // $(document).ready(function() {
        //     $(".content img").bind("mousewheel", function() {
        //         zoomImg(this);
        //         return false;
        //     });
        // });
        // $(document).on("mousewheel", ".content img", function() {
        //     zoomImg(this);
        //     return false;
        // });
    })

});

// 切换到可编辑状态
// 自客信息
$(document).on("click", "#zinews", function() {
    $("#zinews-previwe").css("display", "none");
    $("#zinews-edit").css("display", "block");
});
// 自客编辑
$(document).on("click", "#zinews-suceesn", function() {

    var _name         = $('#name').val();
    var _city         = $('#city').val();
    var _job          = $('#job').val();
    var _work_time_id = $('#work_time_id').val();
    var _head_img     = $('#upload-headImg').attr('src');

    var _skills_ids = 0;
    var _skill_obj = $('#select-skill span');
    for (var i=0;i<_skill_obj.length;i++){
        var _skill_o = _skill_obj[i];
        if(i != 0){
            _skills_ids += ',' + $(_skill_o).attr('value');
        }else{
            _skills_ids  = $(_skill_o).attr('value');
        }
    }

    var _free_time = $('#summary-text').val();
    var _mobile    = $('#com-phone').val();
    var _code      = $('#com-code').val();
    var _wecheat   = $('#weixin').val();
    var _company   = $('#company').val();
    var _field_id  = $('#field_id').val();
    var _label_id  = $('.skill-df').find('.active').attr('value');

    var nameReg     = !!_name.match(/^[a-zA-Z\u4e00-\u9fa5]{2,10}$/gi);
    var vocationReg = !!_job.match(/^[A-Za-z\u4e00-\u9fa5]{2,20}$/gi);

    if(!_name){
        updateAlert("请填写你的姓名", 'alert-error');
        return;
    }
    if (nameReg == false) {
        updateAlert("姓名需为2-10个汉字或英文字母", 'alert-error');
        return;
    }
    if(!_city || _city == 0){
        updateAlert("请选择城市", 'alert-error');
        return;
    }
    if(!_job){
        updateAlert("请填写你的职业", 'alert-error');
        return;
    }
    if(!_label_id){
        updateAlert("请选择技能类别", 'alert-error');
        return;
    }
    if (vocationReg == false) {
        updateAlert("职业需为2-20个汉字或英文字母", 'alert-error');
        return;
    }
    if(!_work_time_id || _work_time_id == 0){
        updateAlert("请选择工作年限", 'alert-error');
        return
    }
    if(!_field_id || _field_id == 0){
        updateAlert("请选择擅长领域", 'alert-error');
        return
    }
    if(!_skills_ids || _skills_ids == 0){
        updateAlert("请选择技能标签", 'alert-error');
        return;
    }
    if(!_free_time){
        updateAlert("请填写你方便服务的时间", 'alert-error');
        return;
    }
    if(!_head_img || _head_img == '/Public/Home/images/ziworker_headportrait200px.png'){
        updateAlert("请上传你的头像", 'alert-error');
        return;
    }

    var telReg   = !!_mobile.match(/^(0|86|17951)?(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9])[0-9]{8}$/);
    var weixiReg = !!_wecheat.match(/^[a-zA-Z\d_]{4,}$/);

    if(!_mobile){
        updateAlert("请填写你的手机号码", 'alert-error');
        return;
    }
    if(telReg == false){
        updateAlert("手机号格式不正确","alert-error");
        return;
    }

    if(_wecheat && weixiReg == false){
        updateAlert("微信号需为4-26个英文字母或数字","alert-error");
        return;
    }

    if($('#verify_code').css('display') == 'block'){
        if(!_code){
            updateAlert("请填写短信验证码", 'alert-error');
            return;
        }
        if(_code.length != '4'){
            updateAlert("短信验证码格式不正确", 'alert-error');
            return;
        }
    }

    var _data_url = $('#zinews-suceesn').attr('data-url');
    var _go_url   = $('#zinews-suceesn').attr('go-url');

    $.ajax({
        type:'POST',
        dataType:'json',
        url: _data_url,
        data: {'name':_name,'city_id':_city,'job':_job,'work_time_id':_work_time_id,'skill_ids':_skills_ids,'free_time':_free_time,'mobile':_mobile,'code':_code,'weixin':_wecheat,'company':_company,'field_id':_field_id,'head_img':_head_img,'label_id':_label_id},
        success: function(obj){
            if(obj.status == 1){

                /*$("#zinews-previwe").css("display", "block");
                $("#zinews-edit").css("display", "none");
                $(window).scrollTop(0);*/

                /*updateAlert(obj.info,"alert-success");

                $('.info-head-left').children('img').attr('src',_head_img);
                $('#upload-headImg').attr('default-value',_head_img);

                $("#zinews-previwe").css("display", "block");
                $("#zinews-edit").css("display", "none");*/


                if(!_go_url){
                    //setInterval(function(){
                        window.location.reload();
                    //}, 1500);
                }else{
                    window.location.href = _go_url;
                }

            }else{
                updateAlert(obj.info,"alert-error");
            }
        }
    });
    // $('html,body').animate({ scrollTop: '0px' }, 800);
});

$(document).on("click", "#zinews-cancel", function() {

    var img_default_src = $('#upload-headImg').attr('default-value');
    var img_cur_src     = $('#upload-headImg').attr('src');
    if(img_default_src != img_cur_src){
        is_confirm1 = 1;
    }

    var arr = $('#select-skill').find('span')

    if(_skill_ids.length != arr.length){
        is_confirm1 = 1
    }

    $.each(arr, function(i) {
        var obj = arr[i];
        var val = $(obj).attr('value')
        if($.inArray(val, _skill_ids) == -1){
            is_confirm1 = 1;
        }
    });

    if(is_confirm1 == 1){
        $.confirm("提示", "确定不保存信息？", function() {

            var _name         = $('#name').attr('default-value');
            var _job          = $('#job').attr('default-value');
            var _head_img     = $('#upload-headImg').attr('default-value');
            var _free_time    = $('#summary-text').attr('default-value');
            var _free_time_c  = $('#misstext').attr('default-value');
            var _mobile       = $('#com-phone').attr('default-value');
            var _wecheat      = $('#weixin').attr('default-value');
            var _company      = $('#company').attr('default-value');
            var _work_time_id = $('#work_time_id').attr('default-value');
            var _field_id     = $('#field_id').attr('default-value');
            var _province     = $('#province').attr('default-value');
            var _city         = $('#city').attr('default-value');

            $('#name').val(_name);
            $('#job').val(_job);
            $('#upload-headImg').attr('src',_head_img);
            $('#summary-text').val(_free_time);
            $('#misstext').html(_free_time_c);
            $('#com-phone').val(_mobile);
            $('#weixin').val(_wecheat);
            $('#company').val(_company);
            $('#work_time_id').val(_work_time_id);
            $('#field_id').val(_field_id);
            $('#province').val(_province);

            var pid      = _province;
            var data_url = $('#province').attr('data-url')
            if(pid != 0){
                $.ajax({
                    type: "POST",
                    url: data_url,
                    data: {'pid':pid},
                    dataType: "json",
                    success: function(res){
                        if(res.status){
                            var html = '<option value="0">请选择</option>';
                            $.each(res.list, function(i) {

                                if(res.list[i]['id'] == _city){
                                    html += '<option value="'+res.list[i]['id']+'" selected>'+res.list[i]['name']+'</option>';
                                }else{
                                    html += '<option value="'+res.list[i]['id']+'">'+res.list[i]['name']+'</option>';
                                }
                            });
                            $('#city').html(html);
                        }
                    }
                });
            }else{
                $('#city').html('<option value="0">请选择</option>');
            }

            $('#select-skill').html(_select_txt);
            $('#skill_text').html(_skill_txt);
            $('#skill_area').html(_area_txt);

            $("#zinews-previwe").css("display", "block");
            $("#zinews-edit").css("display", "none");
            // $('html,body').animate({ scrollTop: '0px' }, 400);
            $(window).scrollTop(0);

        }, function() {
            return false;
        });
        $('body').css('padding-right', '0');

        is_confirm1 = 0

    }else{
        $("#zinews-previwe").css("display", "block");
        $("#zinews-edit").css("display", "none");
        $(window).scrollTop(0);
    }

});
// 关于自客
$(document).on("click", "#ziaubot", function() {
    $("#ziaubot-previwe").css("display", "none");
    $("#ziaubot-edit").css("display", "block");
});
// 关于自客编辑
$(document).on("click", "#ziaubot-suceesn", function() {

    var data_url = $('#ziaubot-suceesn').attr('data-url');
    var is_zero  = 0;
    var arr = $('.small-firstImgShow');
    $.each(arr, function(i) {
        var obj = arr[i];
        if($(obj).css('display') == 'block'){
            is_zero = 1;
        }
    });

    if(is_zero == 1){
        var k = 1;
    }else{
        var k = 0;
    }

    var img = [];
    var img_arr = $('.smallImg');
    for (var i=0;i<img_arr.length;i++){
        var img_obj = img_arr[i];
        var img_src = $(img_obj).attr('src');
        var img_css = $(img_obj).prev().css('display');
        if(img_css == 'block'){
            img[0] = img_src;
        }else{
            img[k] = img_src;
            k++;
        }
    }

    var img_txt = img.join(' ');
    if(!img_txt){
        updateAlert("至少上传一张个人照片","alert-error");
        return;
    }

    var brief = $('#aubot-textarea').val();

    var miss = $("#aubot-textarea").val();
    var mission = miss.length;
    if(mission < 10){
        updateAlert("自我介绍不得少于10个字","alert-error");
        return;
    }

    /*if(img.length == 0 && !brief){
        $("#ziaubot-previwe").css("display", "block");
        $("#ziaubot-edit").css("display", "none");
        return;
    }*/

    $.ajax({
        type:'POST',
        dataType:'json',
        url: data_url,
        data: {'img':img_txt,'brief':brief},
        success: function(obj){
            if(obj.status == 1){
                updateAlert(obj.info,"alert-success");
                setInterval(function(){
                    window.location.reload();
                }, 2000);
            }else{
                updateAlert(obj.info,"alert-error");
            }
        }
    });

});
$(document).on("click", "#ziaubot-cancel", function() {

    var arr = $('.zi-small-imglist')

    if(_photo_ids.length != arr.length){
        is_confirm2 = 1
    }

    $.each(arr, function(i) {
        var obj = arr[i];
        var val = $(obj).find('img').attr('src')
        if($.inArray(val, _photo_ids) == -1){
            is_confirm2 = 1;
        }
    });

    if(is_confirm2 == 1){
        $.confirm("提示", "确定不保存信息？", function() {

            var brief = $('#aubot-textarea').attr('default-value');
            var miss  = $("#brieftext").attr('default-value');

            $('#aubot-textarea').val(brief);
            $("#brieftext").html(miss);

            if(_img_small.indexOf("zi-small-imglist") != -1){
                $('.js_uploadBox').hide();
                $('.js_showBox').show();
            }

            $('.zi-img-show').html(_img_big);
            $('.zi-small-img-list').html(_img_small);

            $("#ziaubot-previwe").css("display", "block");
            $("#ziaubot-edit").css("display", "none");

        }, function() {
            return false;
        });

        $('body').css('padding-right', '0');

        is_confirm2 = 0;
    }else{
        $("#ziaubot-previwe").css("display", "block");
        $("#ziaubot-edit").css("display", "none");
    }

});
// 项目案例
// 添加案例
$(document).on("click", "#zicase-add", function() {

    $('#edit-id').val('');
    $('#uploadImgBtn').html('<div class="upload-head-img pr tc fl img-list img-list-up">' +
        '<span class="di icon-icon_upload font-s30 colordbd mt-40"></span>' +
        '<input id="other_inputFile" type="file" class="inputClass cp other_inputFile"  name="upload-file">' +
        '</div>' +
        '<div class="clear"></div>');
    $('#pro_name').val('');
    $('#pro_duty').val('');
    $('#pro-textarea').val('');
    $('#pro_url').val('');
    $("#case_count").text("0/500");

    $("#zicase-previwe").css("display", "none");
    $("#zicase-edit").css("display", "block");
});
// 编辑案例
$(document).on("click", "#zicase-bun-edit", function() {

    $('#edit-id').val('');
    $('#uploadImgBtn').html('<div class="upload-head-img pr tc fl img-list img-list-up">' +
        '<span class="di icon-icon_upload font-s30 colordbd mt-40"></span>' +
        '<input id="other_inputFile" type="file" class="inputClass cp other_inputFile"  name="upload-file">' +
        '</div>' +
        '<div class="clear"></div>');
    $('#pro_name').val('');
    $('#pro_duty').val('');
    $('#pro-textarea').val('');
    $('#pro_url').val('');
    $("#case_count").text("0/500");

    $("#zicase-addhtml").css("display", "none");
    $("#zicase-edit").css("display", "block");
});
$(document).on("click", "#zicase-suceesn", function() {

    var pro_name     = $('#pro_name').val();
    var pro_duty     = $('#pro_duty').val();
    var pro_textarea = $('#pro-textarea').val();
    var pro_url      = $('#pro_url').val();

    if(pro_url){
        //var reg1=/^(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$/;
        //var reg2=/^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$/;
        //if(!reg1.test(pro_url) && !reg2.test(pro_url)){
        //    updateAlert('作品链接需为网址',"alert-error");
        //    return;
        //}

        var strRegex = "^((https|http|ftp|rtsp|mms)?://)"
        //    + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" //ftp的user@
        //    + "(([0-9]{1,3}\.){3}[0-9]{1,3}" // IP形式的URL- 199.194.52.184
        //    + "|" // 允许IP和DOMAIN（域名）
        //    + "([0-9a-z_!~*'()-]+\.)*" // 域名- www.
        //    + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // 二级域名
        //    + "[a-z]{2,6})" // first level domain- .com or .museum
        //    + "(:[0-9]{1,4})?" // 端口- :80
        //    + "((/?)|" // a slash isn't required if there is no file name
        //    + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
        var re = new RegExp(strRegex);
        if(!re.test(pro_url)){
            updateAlert('项目链接需要“http://”或者“https://”开头',"alert-error");
            return;
        }
    }

    var img = [];
    var img_obj = $('.u-list img');
    $.each(img_obj, function(i) {
        img[i] = $(img_obj[i]).attr('src');
    });

    var data_url = $("#zicase-suceesn").attr('data-url');
    var img_txt = img.join(' ');

    var edit_id = $('#edit-id').val();

    $.ajax({
        type:'POST',
        dataType:'json',
        url: data_url,
        data: {'img':img_txt,'pro_name':pro_name,'pro_duty':pro_duty,'pro_textarea':pro_textarea,'pro_url':pro_url,'id':edit_id},
        success: function(obj){
            if(obj.status == 1){
                updateAlert(obj.info,"alert-success");
                setInterval(function(){
                    window.location.reload();
                }, 2000);
            }else{
                updateAlert(obj.info,"alert-error");
            }
        }
    });
    /*$("#zicase-edit").css("display", "none");
    $("#zicase-previwe").css("display", "block");*/
});
$(document).on("click", "#zicase-cancel", function() {

    var arr = $('.u-list')

    if(_project_pics.length != arr.length){
        is_confirm3 = 1
    }

    $.each(arr, function(i) {
        var obj = arr[i];
        var val = $(obj).find('img').attr('src').toString()

        if($.inArray(val, _project_pics) == -1){
            is_confirm3 = 1;
        }
    });

    if(is_confirm3 == 1){
        $.confirm("提示", "确定不保存信息？", function() {

            $("#zicase-edit").css("display", "none");
            $("#zicase-previwe").css("display", "block");
            /*$(".case-card").css("display", "block");
             $(".pb-30").css("display", "none");*/
            $("#zicase-addhtml").show();

        }, function() {
            return false;
        });

        $('body').css('padding-right', '0');

        is_confirm3 = 0;
    }else{
        $("#zicase-edit").css("display", "none");
        $("#zicase-previwe").css("display", "block");

        $("#zicase-addhtml").show();
    }
});
// 编辑删除 按钮
$(document).on("click", "#zicase-remove-anli", function() {
    var obj = $(this);
    $.confirm("提示", "确认删除此条项目案例？", function() {
        var id       = obj.attr('del-id');
        var data_url = obj.attr('data-url');
        $.ajax({
            type:'POST',
            dataType:'json',
            url: data_url,
            data: {'id':id},
            success: function(obj){
                if(obj.status == 1){
                    updateAlert(obj.info,"alert-success");
                    setInterval(function(){
                        window.location.reload();
                    }, 2000);
                }else{
                    updateAlert(obj.info,"alert-error");
                }
            }
        });
    });
    $('body').css('padding-right', '0');
});
$(document).on("click", "#zicase-edit-anli", function() {

    var data_id = $(this).attr('data-id');

    var edit_id = $(this).attr('edit-id');
    $('#edit-id').val(edit_id);

    $('#uploadImgBtn').html('<div class="upload-head-img pr tc fl img-list img-list-up">' +
        '<span class="di icon-icon_upload font-s30 colordbd mt-40"></span>' +
        '<input id="other_inputFile" type="file" class="inputClass cp other_inputFile"  name="upload-file">' +
        '</div>' +
        '<div class="clear"></div>');

    $('#pro_name').val('');
    $('#pro_duty').val('');
    $('#pro-textarea').val('');
    $('#pro_url').val('');

    var pro_url      = $('#pro-url'+data_id).attr('href');
    var pro_name     = $('#pro-name'+data_id).html();
    var pro_duty     = $('#pro-duty'+data_id).html();
    var pro_describe = $('#pro-describes'+data_id).val();
    var pro_obj      = $('#pro-pic'+data_id).find('a');
    var html         = '';

    var mission = pro_describe.length;
    $("#case_count").text(mission + "/500");

    var pro_text = '';

    $.each(pro_obj, function(i) {
        //alert(pro_obj[i])
        html += '<div class="upload-head-img pr tc fl img-list u-list">' +
                '<img src="'+pro_obj[i]+'" width="160" height="120">' +
                '<span class="zi-changeImg">更换作品</span>' +
                '<input type="file" class="inputClass changeImg cp" name="upload-file">' +
                '<span class="delete-ico font-s24 icon-icon_del del-icon" data-sid="'+i+'" id="other_img_'+i+'"></span>' +
                '</div>';

        _project_pics[i] = pro_obj[i].toString();

    });

    if(pro_obj.length < 5){
        html += '<div class="upload-head-img pr tc fl img-list img-list-up">' +
            '<span class="di icon-icon_upload font-s30 colordbd mt-40"></span>' +
            '<input id="other_inputFile" type="file" class="inputClass cp other_inputFile"  name="upload-file">' +
            '</div>' +
            '<div class="clear"></div>';
    }else{
        html += '<div class="upload-head-img pr tc fl img-list img-list-up" style="display: none;">' +
            '<span class="di icon-icon_upload font-s30 colordbd mt-40"></span>' +
            '<input id="other_inputFile" type="file" class="inputClass cp other_inputFile"  name="upload-file">' +
            '</div>' +
            '<div class="clear"></div>';
    }


    $('#uploadImgBtn').html(html);

    $('#pro_name').val(pro_name);
    $('#pro_duty').val(pro_duty);
    $('#pro-textarea').val(pro_describe);
    pro_url != 'javascript:void(0);' && $('#pro_url').val(pro_url);

    _pro_name = pro_name;
    _pro_duty = pro_duty;
    _pro_describe = pro_describe;
    if(!pro_url){
        _pro_url = 0;
    }else{
        _pro_url = pro_url;
    }

    /*var _html = $('#zicase-edit').html();

    $(this).parent().parent().hide();
    $(this).parent().parent().after(_html);*/

    $("#zicase-previwe").css("display", "none");
    $("#zicase-edit").css("display", "block");
});

var top_alert = $("#top-alert");

function updateAlert(text, c) {
    text = text || 'default';
    c = c || false;
    if (text != 'default') {
        top_alert.find('.alert-content').text(text);
        if (top_alert.hasClass('block')) {} else {
            top_alert.addClass('block').slideDown(200);
        }
    } else {
        if (top_alert.hasClass('block')) {
            top_alert.removeClass('block').slideUp(200);
        }
    }
    if (c != false) {
        top_alert.removeClass('alert-error alert-warn alert-info alert-success').addClass(c);
    }
    setTimeout(function() {
        if ($('#top-alert').is(":visible")) {
            $('#top-alert').find('.close').click();
        }
    }, 2000)
};
top_alert.find('.close').on('click', function() {
    top_alert.removeClass('block').slideUp(200);
});

//如果编辑状态，点击了浏览器的返回，刷新，以及页面跳转提示
/*
window.onbeforeunload=function(){
    if($(".nosaveMessage").css('display')=='block'){
        return "你确认离开此页面吗？你输入的数据将不会保存?";
    }
    if($(".nosaveMessage2").css('display')=='block'){
        return "你确认离开此页面吗？你输入的数据将不会保存?";
    }
    if($(".nosaveMessage3").css('display')=='block'){
        return "你确认离开此页面吗？你输入的数据将不会保存?";
    }
}*/